package com.luoqiu.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 洛秋y
 * @date 2020/11/24 14:47
 */
@RestController
public class FlowLimitController {

    @GetMapping(value = "/sentinel/A")
    public String A() {
        return "A";
    }

    @GetMapping(value = "/sentinel/B")
    public String B() {
        return "B";
    }

    @GetMapping(value = "/hotkey")

    @SentinelResource(value = "hotkey", blockHandler = "dealHotKey")
    public String testHot(@PathVariable(name = "p1", required = false) String p1, @PathVariable(name = "p2", required = false) String p2) {

        return "t1t2";
    }

    public String dealHotKey(String p1, String p2, BlockException exception) {

        return "dealHotKey";
    }
}
